<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    public function up(): void
    {
        Schema::create('contract_sign_histories', function (Blueprint $table) {
            $table->id();
            $table->string('task_id');
            $table->unsignedBigInteger('freelancer_id');
            $table->string('apply_no')->unique();
            $table->string('status')->default('pending');
            $table->timestamps();

            $table->index('task_id');
            $table->index('freelancer_id');

            $table->foreign('freelancer_id')->references('id')->on('freelancers')->cascadeOnDelete();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('contract_sign_histories');
    }
};
